import request from '@/request/index'

/**
 * 用户注册
 * @param data
 */
export const userRegister = async (data: any) => {
  return request({
    url: '/api/user/register',
    method: 'post',
    data
  })
}
/**
 * 用户登录
 * @param data
 */
export const userLogin = async (data: any) => {
  return request({
    url: '/user/login',
    method: 'post',
    data
  })
}

/**
 * 获取用户列表
 * @param username
 */
export const getUserList = async (username: string) => {
  return request({
    url: '/user/search',
    method: 'get',
    data: username
  })
}
/**
 * 删除用户
 */
export const deleteUser = async (id: string) => {
  return request({
    url: '/api/user/delete',
    method: 'post',
    data: id,
    // JSON格式
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

/**
 * 获取当前用户信息
 * @param username
 */
export const getCurrentUser = async () => {
  return request({
    url: `/user/current`,
    method: 'get'
  })
}
